package app.controller.goods;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import app.model.goods.GoodsDeliveryRecords;
import app.service.goods.GoodsDeliveryRecordsService;
import app.util.ServletUtil;
import base.JsonResult;
import base.PageInfo;

@Controller
@RequestMapping("/goodsDeliveryRecords")
public class GoodsDeliveryRecordsController {
	
	private Logger logger = Logger.getLogger(GoodsDeliveryRecordsController.class);
	
	@Autowired
	private GoodsDeliveryRecordsService goodsDeliveryRecordsService;
	
	@ResponseBody
	@RequestMapping("/list.do")
	public PageInfo list(PageInfo pageInfo,HttpServletRequest request){
		Map<String, Object> parameterMap = ServletUtil.getParameterMap(request);
		return goodsDeliveryRecordsService.list(pageInfo,parameterMap);
	}
	
	@ResponseBody
	@RequestMapping("/save.do")
	public JsonResult save(GoodsDeliveryRecords goodsDeliveryRecords){
		if(StringUtils.isEmpty(goodsDeliveryRecords.getId())){
			goodsDeliveryRecordsService.saveEntity(goodsDeliveryRecords);
		}else{
			goodsDeliveryRecordsService.updateEntity(goodsDeliveryRecords);
		}
		return new JsonResult("操作成功");
	}
	
	@ResponseBody
	@RequestMapping("/view.do")
	public JsonResult view(String id){
		GoodsDeliveryRecords goodsDeliveryRecords = goodsDeliveryRecordsService.queryEntityById(id);
		return new JsonResult("操作成功",goodsDeliveryRecords);
	}
	
	@ResponseBody
	@RequestMapping("/del.do")
	public JsonResult del(String ids){
		goodsDeliveryRecordsService.delEntity(ids);
		return new JsonResult("操作成功");
	}
}
